listen

open suspend override fun listen(channel: String, f: (Notification) -> Unit)

Listens to a specific PostgreSQL channel and processes notifications using the provided callback function.

This method leverages the PostgreSQL listen/notify mechanism to receive notifications on the specified channel. It delegates the listening task to the listen method that supports multiple channels.

Parameters

channel

The name of the PostgreSQL channel to listen to. This represents a single PostgreSQL listen/notify channel.

f

A callback function that is invoked for each notification received. The function accepts a Notification object containing the channel name and the notification payload.


open suspend override fun listen(channels: List<String>, f: (Notification) -> Unit)

Listens to notifications on the specified PostgreSQL channels and processes them using the provided callback function. The notifications are received via the PostgreSQL listen/notify mechanism.

Parameters

channels

A list of channel names to listen to. The list must not be empty. Each channel represents a PostgreSQL listen/notify channel.

f

A callback function that is invoked for each notification received. The function accepts a Notification object containing the channel name and the notification payload.

Throws

If the channels list is empty.